<?php
/**
 * Created by PhpStorm.
 * User: jocky
 * Date: 07/10/2017
 * Time: 15:08
 */
?>
<div class="row">
    <div class="col-md-12">
        <form class="form-horizontal" id="form_moneyRecharge">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">入金</h3>
                </div>
                <div class="panel-body">
                    <div class="row">
                        <div class="col-md-8">
                            <div class="form-group">
                                <label class="col-md-4 control-label">支付方式</label>
                                <div class="col-md-8">
                                    <select class="form-control" name="payType" id="pay_Mode">
                                        <option value='1'>网关支付</option>
                                        <option value="2">支付宝</option>
                                    </select>
                                    <br />
                                    <div id="thediv">
                                        <select class="form-control" name="bank">
                                            <option value='0'>请选择支付银行</option>
                                            <?php
                                            for ($i=1;$i<count($banks);$i++){

                                                echo "<option value='".$banks[$i]['value']."'>".$banks[$i]['pay_name']."</option> \n";
                                            }
                                            ?>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-md-4 control-label">金额</label>
                                <div class="col-md-8">
                                    <div class="input-group">
                                        <span class="input-group-addon"><span class="fa fa-cny"></span></span>
                                        <input type="number" class="form-control" name="money" min="0" step="1000"
                                               placeholder="入金金额" data-error="金额为大于0的数字" id="input3" onpropertychange="cop()" oninput="cop()">
                                    </div>
                                    <input type="hidden" value="<?=$RMB?>" id="rmb"/>
                                    <input id="input4" type="text" style="border-style:solid; border-width:0; text-align: right; font-size: 18px; width:70%; color:#D1D1D1; display:none;" />
                                    <span class="help-block">
                                        <?= $rechargeRemark; ?>
                                    </span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-md-4 control-label"></label>
                                <div class="col-md-8">
                                    <button type="button" class="btn btn-info btn-block" onclick="rechargesObj.submit()">
                                        入 金
                                    </button>
                                </div>
                            </div>
                        </div>

                    </div>

                </div>
            </div>
            <?php
            echo \yii\helpers\Html::hiddenInput(
                Yii::$app->request->csrfParam,
                Yii::$app->request->getCsrfToken()
            );
            ?>
        </form>
    </div>

    <div class="col-md-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">入金记录</h3>
                <ul class="panel-controls">
                    <li>
                        <a href="javascript:void(0)" class="panel-fullscreen"
                           onclick="panel_fullscreen($(this).parents(' .panel'));">
                            <span class="fa fa-expand"></span>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)" class="panel-refresh" onclick="rechargesObj.history(3,0)">
                            <span class="fa fa-refresh"></span>
                        </a>
                    </li>
                </ul>
            </div>
            <div class="panel-body">
                <form class="form-inline" role="form" id="form_moneyRechargeHistory">
                    <div class="form-group">
                        <label class="sr-only">开始时间</label>
                        <input name='from'
                               type="text"
                               class="form-control datepicker"
                               placeholder="开始时间"
                               value="<?= date('Y-m-d', $from) ?>">
                    </div>
                    <div class="form-group">
                        <label class="sr-only">结束时间</label>
                        <input name="to"
                               type="text"
                               class="form-control datepicker"
                               placeholder="结束时间"
                               value="<?= date('Y-m-d', $to) ?>">
                    </div>
                    <div class="form-group">
                        <label class="sr-only">状态</label>
                        <select class="form-control" name="status">
                            <option value="-1">状态 - 全部</option>
                            <option value="1">状态 - 请求中</option>
                            <option value="2">状态 - 成功</option>
                            <option value="3">状态 - 失败</option>
                            <option value="4">状态 - 已过期</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <button type="button" class="btn btn-block btn-default" onclick="rechargesObj.history(1,1)">
                            查 询
                        </button>
                    </div>
                </form>
                <br/>
                <div class="table-responsive">
                    <table class="table table-striped table-bordered" id="moneyRechargeHistory_table">
                        <thead>
                        <tr>
                            <th>时间</th>
                            <th class="text-center">支付方式</th>
                            <th>状态</th>
                            <th class="text-right">金额</th>
                        </tr>
                        </thead>
                        <tbody></tbody>
                    </table>
                </div>
            </div>
            <div class="panel-footer">
                <form class="form-inline text-center">
                    <div class="form-group">
                        <button class="btn-block btn btn-default" type="button" onclick="rechargesObj.history(1,1)">
                            &lt;&lt;
                        </button>
                    </div>
                    <div class="form-group">
                        <button class="btn-block btn btn-default" type="button" onclick="rechargesObj.history(2,1)">
                            &lt;
                        </button>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon">
                                共 <span id="moneyRechargeHistory_pageTotal"> </span> 页
                            </span>
                            <input type="number"
                                   min="1"
                                   class="form-control"
                                   id="moneyRechargeHistory_pageNo"
                                   placeholder="请输入要跳转的页码"
                                   value="1"
                                   style="text-align: center;">
                            <span class="input-group-btn">
                                <button type="button"
                                        class="btn btn-default"
                                        onclick="rechargesObj.history(3,0)">
                                    翻 页
                                </button>
                            </span>

                        </div>
                    </div>

                    <div class="form-group">
                        <button class="btn-block btn btn-default" type="button" onclick="rechargesObj.history(2,2)">
                            &gt;
                        </button>
                    </div>
                    <div class="form-group">
                        <button class="btn-block btn btn-default" type="button" onclick="rechargesObj.history(1,2)">
                            &gt;&gt;
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript" src="/js/recharges.js?v=<?= Yii::$app->params['version']; ?>"></script>
<script>
    $('#form_moneyRechargeHistory').find('.datepicker').datepicker({
        autoclose: true,
        format: "yyyy-mm-dd"
    });

    function cop(){
        var str=document.getElementById("input3").value;
        if (str=="") {
            document.getElementById("input4").value="";
            document.getElementById("input4").style.display="none";
        }else{
         document.getElementById("input4").style.display="block";
         var rmb=document.getElementById("rmb").value;
         document.getElementById("input4").value =(((str-str*0.006)/rmb).toFixed(2))+"美元";
        }
    }
</script>